def text_search_num(search_text: str, search: str, overlapping: bool):
    """
    :param search_text: 被查询字符串
    :param search: 查询字符串
    :param overlapping: 是否查询重叠数据，True 重叠可计算，False 不计算重叠
    :return: 返回查询到的子字符串个数
    """
    # 如果查询文本为空，直接返回 0 次
    if search is None:
        return 0
    # 重叠结果也统计
    if overlapping is True:
        # 获取到查询字段的长度
        search_len = len(search)
        result_num = 0
        # 将被查询字段进行遍历
        for i in range(len(search_text)):
            # 按查询字段的长度进行切片，比对查询字段的结果
            if search_text[i:i + search_len] == search:
                # 查询相等，统计字数就 + 1
                result_num = result_num + 1
        return result_num
    # 重叠结果不统计
    elif overlapping is False:
        index_list = []
        search_len = len(search)
        result_num = 0
        for i in range(len(search_text)):
            if search_text[i:i + search_len] == search:
                # 之前的流程跟 overlapping is True 一样，只是这里做个了去重叠
                # 如果被查询子字段与查询字段相等，看下被查询子字段的首个字符索引是否出现了已统计结果的索引中，如果在就跳过，不统计了
                if i in index_list:
                    pass
                # 如果不在，就进行统计，并且将新的子字符串的索引添加到统计结果索引列表中
                else:
                    result_num = result_num + 1
                    for search_num in range(i, i + search_len):
                        index_list.append(search_num)
        print(index_list)
        return result_num


print(text_search_num("bbbbb", 'bbb', False))
